<template>
	<view>
		<!-- 提示窗示例 -->
		<!-- 提示窗示例 -->
		<uni-popup ref="popup" type="dialog">
			<uni-popup-dialog :type="msgType" 
			:cancelText="cancelText" 
			:confirmText="confirmText"
			 :title="title"
				:content="errContent" 
				@confirm="retry" 
				@close="dialogClose"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		name: 'ErrDialog',
		props: {
			dialogData: {
				title: '',
				msgType: '',
				errContent: '',
				confirmText: '',
				functionName: '',
				cancelText:'关闭',
				closeFunction:'',
			}
		
		},
		components: {
			
		},

		data() {
			return {
				// open:false,
				// 标题
				title: '',
				// 弹框提示类型  success / error / warn / info
				msgType: 'success',
				// 主要内容区域文本描述
				errContent: '未知错误,请重试',
				// 右侧按钮文本
				confirmText: '重试',
				// 右侧点击后执行父类的方法名
				functionName: '',
				// 左侧按钮文本描述
				cancelText:'',
				// 关闭时执行的方法(左侧按钮)
				closeFunction:'',
			}
		},

		// 数据变化适用
		onShow() {

		},
		// 页面全部加载完毕后
		mounted() {
			this.init()
			
		},
		created() {

			// this.init()
		},
		methods: {
			myOpen() {
				console.log('open');
				this.show = true
			},
			init() {
				this.title = this.dialogData.title
				this.msgType = this.dialogData.msgType
				this.errContent = this.dialogData.errContent
				this.confirmText = this.dialogData.confirmText
				this.functionName = this.dialogData.functionName
				this.closeFunction = this.dialogData.closeFunction
				this.cancelText = this.dialogData.cancelText
				if(this.title){
					this.dialogToggle("error")
				}
				
			},
			dialogConfirm() {
				this.retry()
			},
			retry() {
				this.$emit("retryFunciton", this.functionName)
			},
			dialogClose() {
				console.log("点击了左侧按钮")
				this.show = false
				if(this.closeFunction){
					this.$emit("retryFunciton", this.closeFunction)
				}
			},
			dialogToggle(type) {
				console.log("提示框加载")
				// this.msgType = type
				// debugger
				// console.log("popup=>"+JSON.stringify(this.$refs.popup))
				this.$refs.popup.open()
				// this.$refs.alertDialog.open()
				// this.show=true
			},
		},
	}
</script>

<style>
</style>